import Vue from 'vue'
import Router from 'vue-router'
import login from '@/components/base/login'

Vue.use(Router)

// 路由懒加载
const home = (resolve) => {
  import ('@/components/base/home').then((module) => {
    resolve(module)
  })
}
const homeDetails = (resolve) => {
  import ('@/components/base/homeDetails').then((module) => {
    resolve(module)
  })
}
const search = (resolve) => {
  import ('@/components/base/search').then((module) => {
    resolve(module)
  })
}
const game = (resolve) => {
  import ('@/components/base/game').then((module) => {
    resolve(module)
  })
}
const join = (resolve) => {
  import ('@/components/base/join').then((module) => {
    resolve(module)
  })
}
const userCenter = (resolve) => {
  import ('@/components/base/userCenter').then((module) => {
    resolve(module)
  })
}


export default new Router({
  routes: [
    {
      path: '/login',
      name: 'login',
      component: login
    },
    {
      path: '/',
      name: 'home',
      meta: {
        // needLogin: true,
        showFooter: true
      },
      component: home
    },
    {
      path: '/homeDetails/:id',
      name: 'homeDetails',
      meta: {
        needLogin: true
      },
      component: homeDetails
    },
    {
      path: '/search',
      name: 'search',
      meta: {
        needLogin: true,
        showFooter: true
      },
      component: search
    },
    {
      path: '/game',
      name: 'game',
      meta: {
        needLogin: true,
        showFooter: true
      },
      component: game
    },
    {
      path: '/join',
      name: 'join',
      meta: {
        needLogin: true,
        showFooter: true
      },
      component: join
    },
    {
      path: '/userCenter',
      name: 'userCenter',
      meta: {
        needLogin: true,
        showFooter: true
      },
      component: userCenter
    }
  ]
})
